/*
 * This action is repose for the main page event such as click menu etc
 */

package com.advertise.strutsAction;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.ServletActionContext;

import com.advertise.model.Menu;
import com.advertise.service.MenuService_IFace;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class MainPageAction {
	
	
	private MenuService_IFace menuService;	   //@Property 1
	
	
	
	public MenuService_IFace getMenuService() {
		return menuService;
	}

	public void setMenuService(MenuService_IFace menuService) {
		this.menuService = menuService;
	}


	private String menuAction;
	
	public String getMenuAction() {
		return menuAction;
	}

	public void setMenuAction(String menuAction) {
		this.menuAction = menuAction;
	}
	

	public String callMenu(){
		
		HttpServletRequest request = ServletActionContext.getRequest();
		
		int clickedMenuId = 0;
		
		if(request.getParameter("clickedMenuId")!=null){
			clickedMenuId = new Integer(request.getParameter("clickedMenuId"));
		}
		
		Menu clickedMenuObj =  menuService.getbyID(clickedMenuId);
		
		menuAction = clickedMenuObj.getMenuAction();
		
		return ActionSupport.SUCCESS;
	}
}
